package com.xjtu.duansheli.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


@Configuration
@Slf4j
public class WebConfigurer extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            log.info("当前操作系统:" + os);
            registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/temp/upload/");
            registry.addResourceHandler("/image/**").addResourceLocations("file:D:/temp/image/");
        } else {
            log.info("当前操作系统:" + os);
            registry.addResourceHandler("/upload/**").addResourceLocations("file:/root/upload/");
            registry.addResourceHandler("/image/**").addResourceLocations("file:/root/image/");
        }
    }
}
